package cn.kgc.Test;

import cn.kgc.config.RabbitmqConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class Producer05_topics_springboot {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("/sendmsg")
    public String sendMsg() {
        for (int i = 0; i < 5; i++) {
            String message = "sms email inform to user" + i;
            rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORN, "inform.sms .email", message);
            System.out.println("Send Message is:'" + message + "'");
        }
        return "success";

    }
}
